@use "../variables" as *;

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  z-index: calc($z-modal - 1);
}

.config-sidebar {
  position: fixed;
  top: 0;
  right: -#{$config-sidebar-width};
  width: $config-sidebar-width;
  height: 100vh;
  background: var(--bg-weak);
  box-shadow: 0 2px 6px var(--shadow);
  transition: all $transition-normal cubic-bezier(0.4, 0, 0.2, 1);
  z-index: $z-modal;
  display: flex;
  flex-direction: column;

  &.visible {
    right: 0;

    &::before {
      opacity: 1;
      pointer-events: auto;
    }
  }

  .config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-weak);
    background: var(--bg-medium);

    h2 {
      margin: 0;
      font-size: 20px;
      font-weight: 500;
    }

    .close-btn {
      padding: 8px;
      background: none;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      color: inherit;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background: var(--bg-op-dark-extremeweak);
      }

      svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
      }
    }
  }

  .config-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-medium);

    @include scrollbar;

    .form-group {
      margin-bottom: 24px;

      label {
        font-weight: 500;
        margin-bottom: 8px;
      }

      &.parameters {
        margin-bottom: 0px;
      }

      .field-description,
      .field-model-description {
        font-size: 13px;
        margin-bottom: 8px;
        color: var(--text-weak);
      }
      .field-model-description {
        margin-bottom: -1rem;
      }

      input, select {
        width: 100%;
        padding: 10px 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        transition: all 0.3s;
        color: var(--text);
        background: var(--bg-input);

        &:focus {
          outline: none;
          border-color: var(--border-pri-blue);
          box-shadow: 0 0 0 2px var(--shadow-input);
        }
      }
      select {
        background: var(--bg-select);
      }
    }

    .form-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
      align-items: center;
    }

    .form-actions {
      display: flex;
      gap: 12px;
      margin-top: 24px;

      button {
        padding: 8px 16px;
        height: 36px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        transition: all 0.3s;
        color: var(--text-light);

        &:disabled {
          opacity: 0.7;
          cursor: not-allowed;
        }

        .loading-spinner {
          @include loading-spinner;
        }
      }

      .verify-btn {
        background: var(--bg-pri-blue);

        &:hover:not(:disabled) {
          background: var(--bg-hover-blue);
        }

        &:active:not(:disabled) {
          background: var(--bg-active-blue);
        }
      }

      .submit-btn {
        background: var(--bg-success);

        &:hover:not(:disabled) {
          background: var(--bg-hover-success);
        }

        &:active:not(:disabled) {
          background: var(--bg-active-success);
        }
      }
    }

    .divider {
      margin: 10px 0;
      height: 1px;
      background: var(--bg-op-dark-ultraweak);
    }

    .parameters-container {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .parameters-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
      align-items: center;

      input[type="number"] {
        -moz-appearance: textfield;
        appearance: textfield;
        grid-column: span 2;
      }

      input[type="number"]::-webkit-outer-spin-button,
      input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
      }

      .parameter-label {
        display: flex;
        align-items: center;
        gap: 8px;

        svg {
          color: var(--stroke-dark-medium);
        }
      }
    }

    .custom-instructions {
      h3 {
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 12px;
      }

      textarea {
        width: 100%;
        min-height: 120px;
        padding: 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        resize: vertical;
        font-size: 14px;
        line-height: 1.5;
        font-family: inherit;
        transition: all 0.3s ease;
        background: var(--bg-input);
        color: var(--text);

        &::placeholder {
          color: var(--text-inverted-weak);
        }

        &:focus {
          outline: none;
          border-color: var(--border-pri-blue);
          box-shadow: 0 0 0 2px var(--shadow-input);
        }
      }

      .custom-instructions-description {
        margin-bottom: 16px;
        font-size: 16px;
        color: var(--text-ultraweak);
      }

      .save-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 8px 16px;
        border: none;
        border-radius: 6px;
        background: var(--bg-pri-blue);
        color: var(--text-light);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        min-height: 36px;

        &:hover:not(:disabled) {
          background: var(--bg-hover-blue);
        }

        &:active:not(:disabled) {
          background: var(--bg-active-blue);
        }

        &:disabled {
          opacity: 0.7;
          cursor: not-allowed;
        }

        .loading-spinner {
          @include loading-spinner;
        }
      }
    }
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}